package com.ciwong.epaper.modules.evaluate.ui.dialogfragment.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.ciwong.epaper.R;
import com.ciwong.epaper.modules.evaluate.ui.dialogfragment.bean.CheckReReadBean;
import com.ciwong.epaper.modules.evaluate.ui.dialogfragment.viewholder.CheckReReadDFrgViewHolder;

import java.util.List;

public class CheckReReadDFrgAdapter extends BaseDFrgAdapter <CheckReReadBean,CheckReReadDFrgViewHolder> {
    public CheckReReadDFrgAdapter(Context context) {
        super(context);
    }

    @Override
    public CheckReReadDFrgViewHolder getViewHolder(LayoutInflater from, ViewGroup parent, int viewType) {
        return new CheckReReadDFrgViewHolder(from.inflate(R.layout.item_reread_lowscore,parent,false));
    }

    @Override
    protected void onBind(final CheckReReadDFrgViewHolder holder, List<CheckReReadBean> list, final int position) {
        final CheckReReadBean checkReReadBean = list.get(position);
        int resid=-1;
        final boolean clickable = checkReReadBean.isClickable();
        if (clickable){
            resid=checkReReadBean.getResId();
        }else{
            resid=checkReReadBean.getResIdHide();
        }
        holder.tvItemName.setSelected(clickable);
//        holder.itemView.setClickable(clickable);
        holder.ivIconLeft.setImageResource(resid);
        holder.tvItemName.setText(checkReReadBean.getItemName());
        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (!clickable) return;//当不可点击时
                if (mListener!=null)
                mListener.checkItem(holder,checkReReadBean,position);
            }
        });
    }

}
